/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#include "database/DataBase.h"
#include "data/Group.h"

namespace acs
{

Group::Group()
{

}

Group::~Group()
{

}

void Group::setID(const int id)
{
	this->id = id;
}

int Group::getID() const
{
	return this->id;
}

void Group::setUpdated(time_t updated)
{
	this->updated = updated;
}

time_t Group::getUpdated() const
{
	return this->updated;
}

void Group::setCreation(time_t creation)
{
	this->creation = creation;
}

time_t Group::getCreation() const
{
	return this->creation;
}

void Group::setName(const std::string& name)
{
	this->name = name;
}

std::string Group::getName() const
{
	return this->name;
}

void Group::setDescription(const std::string& description)
{
	this->description = description;
}

std::string Group::getDescription() const
{
	return this->description;
}

std::string Group::toXML() const
{
	std::stringstream stream;

	stream << "<Group>";
	stream << "<ID>" <<  this->id << "</ID>";
	stream << "<Updated>" <<  this->updated << "</Updated>";
	stream << "<Creation>" <<  this->creation << "</Creation>";
	stream << "<UpdatedStr>" <<  rgcpp::ToString(this->updated,"%Y-%m-%d %X") << "</UpdatedStr>";
	stream << "<CreationStr>" <<  rgcpp::ToString(this->creation,"%Y-%m-%d %X") << "</CreationStr>";
	stream << "<Name>" <<  this->name << "</Name>";
	stream << "<Description>" <<  this->description << "</Description>";
	stream << "<DeviceCount>" <<  DataBase::getInstance()->getGroupDevicesCount(this->id) << "</DeviceCount>";
	stream << "</Group>";

	return stream.str();
}

std::string Group::toXMLFull() const
{
	std::stringstream stream;

	stream << "<Group>";
	stream << "<ID>" <<  this->id << "</ID>";
	stream << "<Updated>" <<  this->updated << "</Updated>";
	stream << "<Creation>" <<  this->creation << "</Creation>";
	stream << "<UpdatedStr>" <<  rgcpp::ToString(this->updated,"%Y-%m-%d %X") << "</UpdatedStr>";
	stream << "<CreationStr>" <<  rgcpp::ToString(this->creation,"%Y-%m-%d %X") << "</CreationStr>";
	stream << "<Name>" <<  this->name << "</Name>";
	stream << "<Description>" <<  this->description << "</Description>";
	stream << "<DeviceCount>" <<  DataBase::getInstance()->getGroupDevicesCount(this->id) << "</DeviceCount>";
	stream << "</Group>";

	return stream.str();
}

}
